<link rel="stylesheet" type="text/css" href="assets/bootstrap-datepicker/css/datepicker.css" />
<section id="container">
  <!--main content start-->
  <section id="main-content">
    <section class="wrapper">
      <!--state overview end-->
      <div class="row">
          <section class="panel">
              <header class="panel-heading">
                  归集结果列表
              </header>
              <div class="panel-body">
                  <div class="row">
                      <div class="col-lg-3" style="position: relative;margin-left:-4px;width: 148px;">
                          <div class="input-group m-bot15">
                              <span class="input-group-addon" style="position: relative;z-index: 2;">年</span>
                              <select class="form-control" id="pyear">
                                  <option value="0">请选择</option>
                                  <option value="2019">2019</option>
                                  <option value="2020">2020</option>
                                  <option value="2021">2021</option>
                                  <option value="2022">2022</option>
                              </select>
                          </div>
                      </div>
                      <div class="col-lg-3" style="margin-left: -16px;width: 125px">
                          <div class="input-group m-bot15">
                              <span class="input-group-addon" style="position: relative;z-index: 2;">月</span>
                              <select class="form-control" id="pmonth">
                                  <option value="0">请选择</option>
                                  <option value="1">1</option>
                                  <option value="2">2</option>
                                  <option value="3">3</option>
                                  <option value="4">4</option>
                                  <option value="5">5</option>
                                  <option value="6">6</option>
                                  <option value="7">7</option>
                                  <option value="8">8</option>
                                  <option value="9">9</option>
                                  <option value="10">10</option>
                                  <option value="11">11</option>
                                  <option value="12">12</option>
                              </select>
                          </div>
                      </div>
                      <div class="col-lg-3" style="width: 200px;">
                          <div class="input-group m-bot15">
                              <span class="input-group-addon">项目名称</span>
                              <input type="text" id="proName" value="" class="form-control">
                          </div>
                      </div>
                      <div class="col-lg-3" style="margin-left: -16px;width: 200px;">
                          <div class="input-group m-bot15">
                              <span class="input-group-addon">工号</span>
                              <input type="text" id="userId" value="" class="form-control">
                          </div>
                      </div>
                      <div class="col-lg-3" style="width: 200px;margin-left: -16px;">
                          <div class="input-group m-bot15">
                              <span class="input-group-addon">公司</span>
                              <select class="form-control"
                                      id="companyCode">
                                  <option value="" selected>全部公司</option>
                                  <option ng-repeat="x in comp" value="{{x.companyId}}">{{x.company}}</option>
                              </select>
                          </div>
                      </div>
                      <!--<div class="col-lg-3" style="margin-left: -16px;width: 165px">-->
                          <!--<div class="input-group m-bot15">-->
                              <!--<span class="input-group-addon">类型</span>-->
                              <!--<select class="form-control" id="lsCostType">-->
                                  <!--<option value="">全部</option>-->
                                  <!--<option value="KF-001">开发成本</option>-->
                                  <!--<option value="YF-001">用服成本</option>-->
                                  <!--<option value="OT-001">销售和管理</option>-->
                                  <!--<option value="N">未分配员工</option>-->
                              <!--</select>-->
                          <!--</div>-->
                      <!--</div>-->
                      <div class="col-lg-3" style="width: 200px;margin-left: -16px;">
                          <div class="input-group m-bot15">
                              <span class="input-group-addon">模块</span>
                              <select class="form-control" id="moduleId">
                                  <option value="0">请选择</option>
                                  <option ng-repeat="xx in moduleList" value="{{xx.moduleId}}">{{xx.moduleName}}
                                  </option>
                              </select>
                          </div>
                      </div>
                      <div class="col-lg-3" style="margin-left: -9px;width: 190px;">
                          <button class="btn btn-info searchhis" style="margin-bottom:15px;">搜索</button>
                          <button class="btn btn-info downLoad" style="margin-bottom:15px;">下载</button>
                      </div>
                  </div>
                  <div id="aContainer" class="dlshouwen-grid-container"></div>
                  <div id="aToolContainer" class="dlshouwen-grid-toolbar-container"></div>

              </div>
          </section>

          <section class="panel">
              <section class="panel">
                  <header class="panel-heading">
                      工时成本计算步骤完成记录
                  </header>
                  <div class="panel-body">
                      <!--历史记录-->
                      <div id="clHistryContainer" class="dlshouwen-grid-container"></div>
                      <div id="clHistryToolContainer" class="dlshouwen-grid-toolbar-container"></div>
                  </div>
              </section>
          </section>
      </div>
    </section>
  </section>
  <!--main content end-->
</section>
<script type="text/javascript" src="assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="js/autocomplete/jquery.autocomplete.js"></script>
<!-- 当前页面js文件引入 -->
<script type="text/javascript">
  function findCrList(CertusFormAjax, $scope) {

      CertusFormAjax.ajax('findMaxTjTime',{},function (result) {
         var y1 = result.data.year;
         var m1 = result.data.month;
         $("#pyear").val(y1);
         $("#pmonth").val(m1);
      });

      CertusFormAjax.ajax('findModuleLists',{},function (response) {
          $scope.moduleList = response.data;
      });

      var companyCode = "";
      CertusFormAjax.ajax("isCrcd", {
          "code": "GJJG"
      }, function (response) {
          var data = JSON.parse(response.data);
          if (data.comanyCode != "") {
              companyCode = data.comanyCode;
              CertusFormAjax.ajax("companyListByCode", {
                  "code": data.comanyCode
              }, function (response) {
                  $scope.comp = JSON.parse(response.data);
              });
          } else {
              CertusFormAjax.ajax("companyListByViewCode", {}, function (response) {
                  var compDate = JSON.parse(response.data);
                  $scope.comp = compDate;
                  for (var i=0;i<compDate.size();i++){
                      if (i == compDate.size()){
                          companyCode = compDate[i].companyId;
                      }else{
                          companyCode = ","+compDate[i].companyId;
                      }
                  }
              });
          }
      });

      this.searchHist = function () {
              //工作安排
          var  hymColumns = [{
                  id: 'userName',
                  title: '姓名',
                  type: 'string',
                  columnClass: 'text-center'
              },{
                  id: 'yd',
                  title: '日期',
                  type: 'string',
                  columnClass: 'text-center'
              }, {
                  id: 'userId',
                  title: '工号',
                  type: 'string',
                  columnClass: 'text-center'
              }, {
                  id: 'company',
                  title: '归属公司',
                  type: 'string',
                  columnClass: 'text-center'
              }, {
                  id: 'dep3_name',
                  title: '归属部门',
                  type: 'string',
                  columnClass: 'text-center'
              }, {
                  id: 'costType',
                  title: '成本种类',
                  type: 'string',
                  columnClass: 'text-center',
                  resolution: function (value, record) {
                      var content = '';
                      if (value=="KF-001") {
                          content = '开发成本';
                      }else if (value=="YF-001"){
                          content = '用服成本';
                      }else if (value=="OT-001"){
                          content = '销管成本';
                      }else if (value==""){
                          content = '未分配';
                      }else {
                          content = '其他';
                      }
                      return content;
                  }
              }, {
                  id: 'createUser',
                  title: '设定人员',
                  type: 'string',
                  columnClass: 'text-center'
              }, {
                  id: 'proName',
                  title: '归属项目',
                  type: 'string',
                  columnClass: 'text-center'
              }, {
                  id: 'moduleName',
                  title: '归属模块',
                  type: 'string',
                  columnClass: 'text-center'
              }, {
                  id: 'createTime',
                  title: '设定时间',
                  type: 'date',
                  format: 'yyyy-MM-dd hh:mm:ss',
                  otype: 'time_stamp_ms',
                  columnClass: 'text-center',
                  width: 180,
                  hideType: 'lg|md|sm|xs'
              }, {
                  id: 'feeEndDate',
                  title: '离职时间',
                  type: 'string',
                  columnClass: 'text-center',
                  width: 110,
                  hideType: 'lg|md|sm|xs'
              }, {
                  id: 'proName',
                  title: '归属项目',
                  type: 'string',
                  columnClass: 'text-center',
                  hideType: 'lg|md|sm|xs'
              }, {
                  id: 'moduleName',
                  title: '归属模块',
                  type: 'string',
                  columnClass: 'text-center',
                  hideType: 'lg|md|sm|xs'
              }, {
                  id: 'comments',
                  title: '注释',
                  type: 'string',
                  columnClass: 'text-center'
              }];

          var pyear = $("#pyear").val();
          var pmonth = $("#pmonth").val();
          var userId = $("#userId").val();
          var pCode = $("#companyCode").val();
          if(pCode!=""){
              companyCode = pCode;
          }
          $("#aContainer").empty();
          $("#aToolContainer").empty();
          CertusFormAjax.ajax('findCareeUserHym', {
              "year": pyear,
              "month":pmonth,
              "userId":userId,
              "deptCode":"",
              "costType":"",
              "company":companyCode,
              "proName":$("#proName").val(),
              "moduleId":$("#moduleId").val()
          }, function (response) {
              var makingOption = {
                  lang: 'zh-cn',
                  ajaxLoad: false,
                  extraWidth: 20,
                  // loadURL:'url',
                  exportFileName: '员工成本',
                  datas: response.data,
                  columns: hymColumns,
                  gridContainer: 'aContainer',
                  toolbarContainer: 'aToolContainer',
                  tools: '',
                  pageSize: 20,
                  pageSizeLimit: [20, 100, 200,500]
              };
              var makingGrid = $.fn.dlshouwen.grid.init(makingOption);
              makingGrid.load();
          });
      };
      setTimeout(function () {
          searchHist();
      },70);
      $(".downLoad").click(function () {
          var lsCostType = "";
          var pyear = $("#pyear").val();
          var pmonth = $("#pmonth").val();
          var userId = $("#userId").val();
          var deptCode = "";

          var pCode = $("#companyCode").val();
          if(pCode!=""){
              companyCode = pCode;
          }

          CertusFormAjax.download("downLoadCareeUserHis", "year="+pyear+"&month="
              + pmonth + "&userId=" + userId + "&deptCode=" + deptCode
              + "&costType=" + lsCostType + "&company=" + companyCode
              +"&proName="+$("#proName").val()+"&moduleId="+$("#moduleId").val());
      });

      $(".searchhis").click(function () {
          searchHist();
      });

      this.searchBz = function () {
          //成本列表
          var clColumns = [{
              id: 'ltime',
              title: '月份',
              type: 'string',
              columnClass: 'text-center'
          },{
              id: 'step1UserName',
              title: '用服确认人',
              type: 'string',
              columnClass: 'text-center',
              width: 60
          }, {
              id: 'step1ConfirmTime',
              title: '用服确认时间',
              type: 'string',
              columnClass: 'text-center',
              width: 100
          }, {
              id: 'step1comment',
              title: '用服说明',
              type: 'string',
              columnClass: 'text-center'
          }, {
              id: 'step2UserName',
              title: '开发确认人',
              type: 'string',
              columnClass: 'text-center',
              width: 60
          }, {
              id: 'step2ConfirmTime',
              title: '开发确认时间',
              type: 'string',
              columnClass: 'text-center',
              width: 100
          }, {
              id: 'step2comment',
              title: '开发说明',
              type: 'string',
              columnClass: 'text-center'
          }, {
              id: 'step3UserName',
              title: '成本确认人',
              type: 'string',
              columnClass: 'text-center',
              width: 60
          }, {
              id: 'step3comment',
              title: '成本说明',
              type: 'string',
              columnClass: 'text-center'
          }, {
              id: 'step3ConfirmTime',
              title: '成本确认时间',
              type: 'string',
              columnClass: 'text-center',
              width: 100
          }, {
              id: 'releaseTime',
              title: '成本计算时间',
              type: 'string',
              columnClass: 'text-center',
              width: 100
          }];

          $("#clHistryContainer").empty();
          $("#clHistryToolContainer").empty();
          CertusFormAjax.ajax('findCmcList', {
          }, function (response) {
              var makingOption = {
                  lang: 'zh-cn',
                  ajaxLoad: false,
                  extraWidth: 20,
                  // loadURL:'url',
                  exportFileName: '员工成本',
                  datas: response.data,
                  columns: clColumns,
                  gridContainer: 'clHistryContainer',
                  toolbarContainer: 'clHistryToolContainer',
                  tools: '',
                  pageSize: 5,
                  pageSizeLimit: [5,10, 15, 20]
              };
              var makingGrid = $.fn.dlshouwen.grid.init(makingOption);
              makingGrid.load();
          });
      };
      searchBz();
  }
</script>